package com.ssj.ssj.exception;

import com.ssj.ssj.util.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Tiandy
 */
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {

    /**
     * 运行时异常
     * @param ex ex
     * @return R
     */
    @ExceptionHandler(RuntimeException.class)
    public R runtimeExceptionHandler(RuntimeException ex) {
        ex.printStackTrace();
        return R.error(ex.getMessage());
    }
}
